<template>
  <div>
      <el-col :span="24">

      <el-col :span="12">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane
            :key="item.jjxId"
            v-for="(item, index) in list"
            :label="item.jjxName"
            :name="item.jjxName"
        >
                    <div>
                        <span>可分配余额：<span class="font22 blue">{{item.jjZe*1-item.bmJj*1}}</span></span>
                        <span class="ml30">已分配金额：<span class="font22 blue">{{item.sum*1==0?item.ygJj*1:item.sum*1}}</span></span>
                    <!-- item.sum*1 item.ygJj -->
                        <span class="ml30">剩余可分配额：<span class="font22 blue">{{item.jjZe*1-item.bmJj*1-(item.sum*1==0?item.ygJj*1:item.sum*1)}}</span></span>
                    </div>
                    <el-table
                        :key="item.jjxId"
                        :data="item.tableData"
                        :ref="'multipleTable'+item.jjxId"
                        :span-method="objectSpanMethod"
                        border
                        max-height="350"
                        @selection-change="handleSelectionChange"
                        style="width: 100%; margin-top: 20px;">
                        <el-table-column
                            type="selection"
                            width="80">
                        </el-table-column>
                        <el-table-column
                            prop="ryfzMc"
                        >
                            <template slot="header" slot-scope="scope">
                                <el-select v-model="name" @change="changeRyfzMc" clearable  placeholder="人员分组">
                                    <el-option
                                    v-for="item in item.checkList"
                                    :key="item.id"
                                    :label="item.ryfzMc"
                                    :value="item.id">
                                    </el-option>
                                </el-select>
                            </template>
                            <template slot-scope="scope">
                                <span style="cursor: pointer;" @click="groupEditing(scope.row,'ry')">{{scope.row.ryfzMc}}({{scope.row.sl}}人)</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="jjxMc"
                            label="奖项">
                            <template slot="header" slot-scope="scope">
                                <el-select v-model="amount" @change="changeJjxMc" clearable  placeholder="奖项">
                                    <el-option
                                    v-for="item in item.valueList"
                                    :key="item.id"
                                    :label="item.jjxMc"
                                    :value="item.id">
                                    </el-option>
                                </el-select>
                            </template>
                            <template slot-scope="scope">
                                <span style="cursor: pointer;" @click="bonusDistribution(scope.row,item.jjxName)">{{scope.row.jjxMc}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="jjxJe"
                            label="输入金额">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.jjxJe" type="number" @blur="blurJjxje(scope.$index,scope.row.gsId)" placeholder=""></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column
                            align="center"
                            label="操作">
                            <template slot-scope="scope">
                                <el-button type="danger" @click="renSplice(scope.$index,item.tableData)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
      </el-tab-pane>
      </el-tabs>
      </el-col>
           <el-col :span="12">
                     <!--人员保存-->
                     <renYuanKeepForm v-show="showRy&&tabName=='first'" ref="renYuanKeepRef" @guan='guan'></renYuanKeepForm>
                </el-col>
      </el-col>
      <!--人员分组-->
    <groupEditingForm ref='groupEditingRef' @refreshDataList="refreshDataList"></groupEditingForm>
    <el-dialog title="奖金分配" width="90vw" height="90vh" top="5vh" append-to-body :close-on-click-modal="false"
               :visible.sync="jiangVisible" v-if="jiangVisible" @close="callbackTwo">
      <jiangjinxiangTable ref="jiangjinxiangRef" @jiangjinxChild="jiangjinxChild"></jiangjinxiangTable>

    </el-dialog>
  </div>
</template>

<script>
import groupEditingForm from '@/views/jiangjin/jiangjinfpjjfpdjb/groupEditing-form'
import jiangjinxiangTable from '@/views/jiangjin/jiangjinfpjjfpdjb/jiangjinxiang-table'
import renYuanKeepForm from '@/views/jiangjin/jiangjinfpjjfpdjb/renYuanKeep-form'
import {getRyfzbList,updateGrNew,getJgfzList,updateBmNew,saveTemplate,pageTemplate,getTemplateBySTa} from "@/api/jiangjin/jiangjinryfzb"
import {getObj, putObj, updateGr,getGsData} from '@/api/jiangjin/jiangjinfpjjfpdjb'
export default {
    components: {
        groupEditingForm,
        jiangjinxiangTable,
        renYuanKeepForm
    },
    name:"renYuan-table",
    props:{
        fromJg:{
            jgdsJiang:0
        }
    },
    data(){
        return{
            activeName:"",
            list:[],
            name:"",
            amount:"",
            spanArr:[],
            pos:0,
            tableDataOld:[],
            tableDataOld:[],
            valueList:[],
            jiangVisible:false,
            showRy:false,
            jjfpId:"",
            deptId:"",
            params:{},
            listTwo:[],
            fpId:"",
            tabName:"",
            valueListThree:[],
            bonusList:[],
            sfCeff:""
        }
    },
    methods:{
        //关闭页面
        guan(guan){
            var renTableChild={
            guan:'关闭'
            }
            this.$emit("renTableChild",renTableChild)
        },
        init(data,jjfpId,deptId,tabName,sfCeff){
            this.listTwo =data
            this.jjfpId=jjfpId
            this.deptId=deptId
            this.tabName=tabName
            this.sfCeff=sfCeff
           ////console.log("this.list:"+JSON.stringify(this.list))
            this.fromJg.jgdsJiang=this.fromJg.jgdsJiang?this.fromJg.jgdsJiang:0
            this.getCs()
        },
        getCs(){
            var params={
                fpId:this.jjfpId,
                fpType:0
            }
            getTemplateBySTa(params).then(res=>{
               ////console.log("人员初始值:"+JSON.stringify(res))
                if(res.data.data){
                    this.list=JSON.parse(res.data.data.fpData)
                    this.showRy=true
                    this.$nextTick(()=>{
                      this.$refs.renYuanKeepRef.init(this.jjfpId)
                        
                    })
                }else{
                    this.list=this.listTwo
                }
                this.activeName = this.list[0].jjxName
                this.getSpanArr(this.list[0].tableData);
                 this.getyue()
                    
            })
        },
        getyue(){
            getObj(this.jjfpId).then(res=>{
                for(var i in this.list){
                    this.list[i].jjYe=JSON.parse(res.data.data.jjxJeXq)[this.list[i].jjxId].jjYe;
                    this.list[i].bmJj=JSON.parse(res.data.data.jjxJeXq)[this.list[i].jjxId].bmJj;
                    this.list[i].ygJj=JSON.parse(res.data.data.jjxJeXq)[this.list[i].jjxId].ygJj;
                    this.list[i].jjZe=JSON.parse(res.data.data.jjxJeXq)[this.list[i].jjxId].jjZe;
                }

            })
        },
        //获取最新公式数据
        getGongs(data){
            var params={
                jjbId:data.jjbId,
                fzId:data.fzId,
                jjxId:data.jxId,
                fpType:'0'
            }
            getGsData(params).then(res=>{
               //console.log("GONGSI:"+JSON.stringify(res.data.data))
                if(res.data.data){
                for(var i in this.list){
                    if(this.activeName==this.list[i].jjxName){
                    for(var j in this.list[i].tableData){
                        if(res.data.data.fzId==this.list[i].tableData[j].fzId&&res.data.data.jjxId==this.list[i].tableData[j].jjxId){
                            this.list[i].tableData[j].gsId=res.data.data.gsId*1
                            if(res.data.data.gsId=='-1'){
                            this.list[i].tableData[j].fzInfo=res.data.data.fzInfo;
                            this.list[i].tableData[j].fzInfo=this.list[i].tableData[j].fzInfo.map(item=>{
                                item.jjJe=0
                                return item
                            })
                            }
                        }
                    }
                    }
                }
                }
            })
        },
        muban(data){
            for(var i in this.list){
                for(var j in data){
                    if(this.list[i].jjxId==data[j].jjxId){
                        this.list[i].tableData=data[j].tableData
                    }
                }
                if(this.activeName==this.list[i].jjxName){
                    this.getSpanArr(this.list[i].tableData);
                    if(this.list[i].tableData.length>0){
                        this.blurJjxje()
                    }
                    
                }
            }
            
        },
        keepMuBan(data){
          
            var params={
                fpId:data.deptId,
                fpName:data.value,
                fpType:0,
                fpSaveType:"b",
                fpData:this.list,
            }
            saveTemplate(params).then(res=>{
                this.$message.closeAll()
                this.$message.closeAll()
                    if(res.data.code==0){
                        this.$message({
                            type: 'success',
                            message: '模板保存成功!'
                        });
                    }
                })
        },
        jiang(value,checkList){
            for(var i in this.list){
                if(this.activeName==this.list[i].jjxName){
                    if(value.length>0){
                        this.list[i].checkList=checkList.filter(y=>{
                            return value.some(x=>{
                                return y.id==x
                            })
                        })
                        var list=[]
                            //this.list[i].tableData = this.list[i].tableData.filter(item => value.includes(item.id))
                            var idSet = this.list[i].tableData.reduce((acc, v) => {
                                acc[v.id] = true;
                                return acc;
                            }, {});

                            // 遍历list2，去掉在idSet中存在的id
                            var result = value.filter(v => !idSet[v]);
                            list =checkList.filter(x=>{
                                return result.some(y=>{
                                        return x.id==y;
                                        })
                            })

                            this.list[i].tableData=this.list[i].tableData.concat(list)
                            this.tableDataOld=this.list[i].tableData;
                      
                        
                        this.getSpanArr(this.list[i].tableData);



                    }else{
                        this.list[i].tableData=[]
                        this.getSpanArr(this.list[i].tableData);
                    }
                }
            }
            
        },
        jigoujiangjin(value, bonusList){
            this.$message.closeAll()
            if(this.multipleSelection.length==0){
                this.$message.warning("请先选择哪些人员分组!")
                this.form.bonus=[]
                return false;
            }
            this.bonusList=bonusList
            this.valueList=bonusList.filter(x=>{
                        return value.some(y=>{
                                return x.id==y;
                                })
                    })

            
            let obj={},jjxMc,obj2={};
            var list=this.multipleSelection,arr=[],arr2=[];

            //this.tableData=arr2
            if(value.length>0){
                for(var i in list){
                    for(var j in this.valueList){

                        obj={
                            jjxMc:this.valueList[j].jjxMc,
                            jjxId:this.valueList[j].id,
                            tenantId:list[i].tenantId,
                            sl:list[i].sl,
                            id:list[i].id,
                            jjDeptId:list[i].jjDeptId,
                            fzXs:list[i].fzXs,
                            ryfzMc:list[i].ryfzMc,
                            ryfzSm:list[i].ryfzSm,
                            ryfzLx:list[i].ryfzLx,
                            deptId:list[i].deptId,
                            dataState:list[i].dataState,
                            createDeptId:list[i].createDeptId,
                            createDeptName:list[i].createDeptName,
                            createUserId:list[i].createUserId,
                            createUserName:list[i].createUserName,
                            createTime:list[i].createTime,
                            fzId:list[i].id,
                            fzName:list[i].ryfzMc,
                            jjxJe:0,
                            gsId:list[i].gsId,
                            gsName:list[i].gsName,
                            jjxDate:list[i].jjxDate,
                            jkjbj:list[i].jkjbj,
                            jjWs:list[i].jjWs,
                            fzInfo:list[i].fzInfo,
                        }
                        //奖金项列表
                        arr.push(obj)

                    }
                }
            }
            else{
                for(var i in list){
                     obj={
                            jjxMc:"",
                            jjxId:"",
                            tenantId:list[i].tenantId,
                            sl:list[i].sl,
                            id:list[i].id,
                            jjDeptId:list[i].jjDeptId,
                            fzXs:list[i].fzXs,
                            ryfzMc:list[i].ryfzMc,
                            ryfzSm:list[i].ryfzSm,
                            ryfzLx:list[i].ryfzLx,
                            deptId:list[i].deptId,
                            dataState:list[i].dataState,
                            createDeptId:list[i].createDeptId,
                            createDeptName:list[i].createDeptName,
                            createUserId:list[i].createUserId,
                            createUserName:list[i].createUserName,
                            createTime:list[i].createTime,
                            fzId:list[i].id,
                            fzName:list[i].ryfzMc,
                            jjxJe:0,
                            gsId:list[i].gsId,
                            gsName:list[i].gsName,
                            jjxDate:list[i].jjxDate,
                            jkjbj:list[i].jkjbj,
                            jjWs:list[i].jjWs,
                            fzInfo:list[i].fzInfo,
                        }
                        //奖金项列表
                        arr.push(obj)
                }
            }

                     const idSet = arr.reduce((acc, v) => {

                        acc[v.id] = true;
                        return acc;
                    }, {});
                    for(var n in this.list){
                        if(this.activeName==this.list[n].jjxName){
                            // 遍历list2，去掉在idSet中存在的id
                            const result = this.list[n].tableData.filter(v => !idSet[v.id]);
                            //去重
                            this.list[n].tableData=this.unique(arr.concat(result))
                            for(var a in this.tableDataOld){
                                    for(var b in this.list[n].tableData){
                                    if(this.tableDataOld[a].id==this.list[n].tableData[b].id&&this.tableDataOld[a].jjxMc!=""&&this.list[n].tableData[b].jjxMc!=""){
                                        this.list[n].tableData=this.unique(this.list[n].tableData.concat(this.tableDataOld[a]))
                                    }
                                    }
                                }
                                for(var z in this.valueList){
                                    for(var e in this.multipleSelection){
                                    var params={
                                        jjbId:this.list[n].jjxId,
                                        fzId:this.multipleSelection[e].fzId,
                                        jxId:this.valueList[z].id,
                                    }
                                    this.getGongs(params)
                                    }
                                }
                            
                                this.valueListThree=this.valueListThree.concat(this.valueList)
                                this.valueListThree=this.uniqueTwo(this.valueListThree)
                                this.list[n].tableData=this.list[n].tableData.filter(item=>{
                                    return this.valueListThree.some(it=>{
                                        if(item.jjxMc!=''){
                                        return it.jjxMc==item.jjxMc
                                        }else{
                                        return item
                                        }
                                        
                                    })
                                })
                            this.list[n].valueList=this.shuaiXuan(this.list[n].tableData)
                            this.tableDataOld=this.list[n].tableData
                            this.getSpanArr(this.list[n].tableData)
                             this.$nextTick(()=>{
                                // this.getSpanArrJiang(this.tableData)
                               // this.toggleSelection(arr)
                                this.blurJjxje()
                               // this.multipleSelection=list;
                                this.$forceUpdate()
                            })
                        }
                    }
        },
        //奖金筛选
        shuaiXuan(data){
            var arr=[]
            this.bonusList.forEach(x => {
                    data.forEach(y => {
                        if(x.id == y.jjxId){
                        arr.push(x)
                        };
                    })
                    })
            return  this.uniqueTwo(arr)
        },
        //去重
        unique(arr) {
        for (var i = 0; i < arr.length; i++) {
            for (var j = i + 1; j < arr.length; j++) {
            if (arr[i].id == arr[j].id && arr[i].jjxId == arr[j].jjxId) {         //第一个等同于第二个，splice方法删除第二个
                arr.splice(j, 1);
                j--;
            }
            }
        }
        return arr;

        },
        //去重奖金项
        uniqueTwo(arr){
        for (var i = 0; i < arr.length; i++) {
            for (var j = i + 1; j < arr.length; j++) {
            if (arr[i].id == arr[j].id) {         //第一个等同于第二个，splice方法删除第二个
                arr.splice(j, 1);
                j--;
            }
            }
        }
       //console.log("arr:"+JSON.stringify(arr))
        return arr;
        },
        toggleSelection(rows) {
            var _this = this;
            for (var i in this.list) {
                if (this.activeName == this.list[i].jjxName) {
                var refs = 'multipleTable' + [this.list[i].jjxId];
                if (rows) {
                    rows.forEach((row,index) => {
                       //console.log(index,row)
                        this.$nextTick(() => {
                            _this.$refs[refs][0].toggleRowSelection(row);
                            })
                    })
                    
                } else {
                    this.$refs[refs][0].clearSelection();
                }
                }

            }
            this.multipleSelection=rows

            },
        blurJjxje(index,gsid) {
            this.$message.closeAll()
            if(gsid==""){
                    this.$message.warning("请先选择计算公式!")
                    return
                }
            this.getnum2()
            for(var i in this.list){
                if(this.activeName==this.list[i].jjxName){
                    if(this.sfCeff=='否'){
                        if(this.list[i].sum*1>(this.list[i].jjZe*1-this.list[i].bmJj*1)){
                        this.list[i].tableData[index].jjxJe=0;
                        this.$message.warning("已分配的金额大于"+this.activeName+"剩余可分配的金额!")
                        this.getnum2()
                        
                        
                    }
                    }
                if(this.activeName==this.list[i].jjxName){
                        this.getSpanArr(this.list[i].tableData);
                        }
            }
            }
            },
            getnum2(){
            for(var i in this.list){
                if(this.activeName==this.list[i].jjxName){
                    var list=this.list[i].tableData.map(item=>{
                        return  item.jjxJe*1
                    // if(item.gsId==-1){
                    //     return  item.jjxJe*item.sl*1
                    // }else{
                    //     return  item.jjxJe*1
                    // }
                    })
                    this.list[i].sum= this.sum(list)
                    var params={
                        activeName:this.list[i].jjxName,
                        jgnum:this.list,
                        dsJiang:this.list[i].sum,
                        jiSuan:true
                    }
                   //console.log("params:"+JSON.stringify(params))
                    this.$emit("renTableChild",params)
                }

                
            }
            },
            //数组总和
            sum(arr) {
                return arr.reduce(function(prev, curr, idx, arr){
                    return prev*1 + curr*1;
                });
            },
        //从奖金项子集过来
        jiangjinxChild(jiangjinxChild){
            this.jiangVisible=false;
            for(var i in this.list){
            if(this.activeName==this.list[i].jjxName){
                this.list[i].tableData=this.list[i].tableData.map(item=>{
                    if(item.id==jiangjinxChild.id&&item.jjxId==jiangjinxChild.jjxId){
                        return jiangjinxChild
                    }else{
                        return item
                    }
                })
            // this.getSpanArrJiang(this.list[i].tableData)
            }
            }
           
        },
        //人员分组
        groupEditing(row, type) {
            var params = {
                activeName: this.activeName,
                row: row,
                type: type
            }
           //console.log("人员传送:"+JSON.stringify(params))
            this.$refs.groupEditingRef.init(params)
        },
        //人员与机构分组删除
        renSplice(index, data) {
            data.splice(index, 1)
            this.getSpanArr(data);
            //this.getSpanArrJiang(data)
        },
        //奖金分配
        bonusDistribution(row,jjxName) {
            this.jiangVisible = true
            this.$nextTick(() => {
                var params = {
                activeName: "first",
                row: row,
                jjxName:jjxName
                }
                this.$refs.jiangjinxiangRef.init(params)
            })
        // this.$refs.bonusDistributionRef.init(this.jjfpId)
        },
        //人员筛选
        changeRyfzMc(value){
            for(var i in this.list){
                if(this.activeName==this.list[i].jjxName){
                    if(value!=""){
                        var  arr=[]
                        this.list[i].tableData=this.tableDataOld;
                        for(var j in this.list[i].tableData){
                            if(this.list[i].tableData[j].id==value){
                                arr.push(this.list[i].tableData[j])
                            }
                        }
                        this.list[i].tableData=arr;
                        this.getSpanArr(this.list[i].tableData)
                    }else{
                        this.list[i].tableData=this.tableDataOld;
                        this.getSpanArr(this.list[i].tableData)
                    }
                    }
            }
        },
        //奖金筛选
        changeJjxMc(value){
            for(var i in this.list){
      
            if(this.activeName==this.list[i].jjxName){
        
            if(value!=""){
                var  arr=[]
                this.list[i].tableData=this.tableDataOld
                for(var j in this.list[i].tableData){
                
                    if(this.list[i].tableData[j].jjxId==value){
                        arr.push(this.list[i].tableData[j])
                    }
                }
                
                this.list[i].tableData=arr;
                this.getSpanArr(this.list[i].tableData)
            }else{
                this.list[i].tableData=this.tableDataOld;
                this.getSpanArr(this.list[i].tableData)
            }
            }
        }
        },
        //合并单元格
        objectSpanMethod({row, column, rowIndex, columnIndex}) {

        if (columnIndex === 0 || columnIndex === 1) {

            const _row = this.spanArr[rowIndex] ? this.spanArr[rowIndex] : 0;
            const _col = _row > 0 ? 1 : 0;

            return {
            // [0,0] 表示这一行不显示， [2,1]表示行的合并数
            rowspan: _row,
            colspan: _col
            };
        }
        },
        //人员分组合并单元格
        getSpanArr(data) {
            function sortData(obj1,obj2){
          return obj1.id-obj2.id
      }
      var dataArr=data.sort(sortData);
        this.spanArr = []
        for (var i = 0; i < dataArr.length; i++) {
            if (i === 0) {
            this.spanArr.push(1);
            this.pos = 0;
            } else {
            // 判断当前元素与上一个元素是否相同
            if (dataArr[i].id === dataArr[i - 1].id) {
            
                this.spanArr[this.pos] += 1;
                this.spanArr.push(0);
            } else {
                this.spanArr.push(1);
                this.pos = i;
            }
            }

        }
        },
        //表格多选
        handleSelectionChange(val) {
            this.multipleSelection=val;
            //  var fzIds=[],jjxIds=[]
            // for(var i in this.list){
            // if(this.activeName==this.list[i].jjxName){
            //      this.list[i].tableData.forEach(item=>{
            //         this.multipleSelection.forEach(it=>{
            //         if(it.fzId==item.fzId){
            //             fzIds.push(item)
            //         }
            //         })
            //     })
            // }
           
            
            //     fzIds=this.unique(fzIds)
            //     fzIds.forEach(item=>{
            //         jjxIds.push(item.jjxId)
            //     })
            //     var buTableChild={
            //     fanXuan:true,
            //     jjxIds:jjxIds
            //     }
                
            ////console.log("人员--")
            //     this.$emit("buTableChild",buTableChild)
            // }
        },
        putUpdateGrNew(data){
            var jjData=[],fpData=[],fzInfo=[],fzInfoJe=0;
            this.fpId=data.fpId
            
            for(var i in this.list){
                    this.$message.closeAll()
                    var list=this.list[i].tableData.filter(item=>{
                        return item.jjxMc==""
                    })
                    var gongshi=this.list[i].tableData.filter(item=>{
                        return item.gsId==""
                    })
                    if(list.length>0){
                        this.$message.warning("存在人员分组未选择奖金项!")
                        return false;
                    }
                    if(gongshi.length>0){
                        this.$message.warning("存在人员分组未选择公式!")
                        return false;
                    }
                    var obj={
                    jjxxqId:this.list[i].jjxId,
                    amt:this.list[i].sum
                    }
                    jjData.push(obj)
                    for(var j in this.list[i].tableData){
                        this.list[i].tableData[j].jjxxqId=this.list[i].jjxId
                        if(this.list[i].tableData[j].gsId==-1){
                            fzInfo=this.list[i].tableData[j].fzInfo.map(item=>{
                                return item.jjJe*1
                            })
                            fzInfoJe=this.sum(fzInfo);
                            if(this.list[i].tableData[j].jjxJe*1!=fzInfoJe){
                                var je=this.list[i].tableData[j].jjxJe*1/this.list[i].tableData[j].sl*1;
                                for(var n in this.list[i].tableData[j].fzInfo){
                                    this.$set(this.list[i].tableData[j].fzInfo[n],'jjJe',je)
                                }
                            }
                            }
                        fpData.push(this.list[i].tableData[j])
                    }
                    
                
            }
            
            this.params={
                fpId:this.fpId,
                fpData:fpData,
                jjYe:data.jjYe,
                jjData:jjData
            }
          this.keepShuJu()
           
        },
        keepShuJu(){
            const loading = this.$loading({
                lock: true,
                text: `正在计算中,请稍后......`,
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            })
            var params={
                fpId:this.fpId,
                fpName:"默认",
                fpType:0,
                fpSaveType:"a",
                fpData:this.list,
            }
            saveTemplate(params).then(res=>{
                 updateGrNew(this.params).then(res=>{
                //console.log(JSON.stringify(res))
                if(res.data.code==0){
                    
                    this.showRy=true
                    this.$nextTick(()=>{
                        //console.log("this.jjfpId:"+this.jjfpId)
                        this.$refs.renYuanKeepRef.init(this.fpId)
                        this.getyue()
                        
                        // for(var i in this.list){
                        //   this.list[i].sum=0
                        //   this.list[i].tableData=[]
                        // }
                        //this.tableData=[];
                       // this.getSpanArrJiang(this.tableData)
                        loading.close()
                    })
                }else{
                    loading.close()
                }

            })
                })
        },
        refreshDataList() {
            //人员分组
            getRyfzbList(this.deptId).then(res=>{
                this.checkList=res.data.data.map(item=>{
                     item.jjxMc=""
                     item.jjxId=""
                     item.jjxJe=0
                     item.fzId=item.id
                     item.fzName=item.ryfzMc;
                     item.gsId=2
                     item.gsName=""
                     item.jjxDate=""
                     item.jkjbj=false
                     item.jjWs="1"
                     item.fzInfo=[]
                    return item
                });
                
                for(var i in this.list){
                    if(this.activeName==this.list[i].jjxName){
                        for(var j in this.list[i].tableData){
                            for(var q in this.checkList){

                                if(this.checkList[q].id==this.list[i].tableData[j].id){
                                    this.list[i].tableData[j].ryfzMc=this.checkList[q].ryfzMc
                                    this.list[i].tableData[j].sl=this.checkList[q].sl
                                }
                            }
                        }
                    }
                    
                }

            })
        },
        callbackTwo() {
            this.jiangVisible = false
        },
        //清除选项
        qingXuan(){
            for(var i in this.list){
                var refs = 'multipleTable' + [this.list[i].jjxId];
                this.$refs[refs][0].clearSelection();
            }
        },
        handleClick(tab){
            for (var i in this.list) {
                if (tab.name == this.list[i].jjxName) {
                this.getSpanArr(this.list[i].tableData)
                
                }
                var refs = 'multipleTable' + [this.list[i].jjxId];
                this.$refs[refs][0].clearSelection();
            }
            var renTableChild={
                qingK:true
            }
            this.$emit("renTableChild",renTableChild);
        },
    }
}
</script>

<style>

</style>